﻿
@{
    Layout = "";
    ViewBag.MenuId = 2;
}

<div class="w_mobile_main_body" ng-controller="SearchIndexCtrl">
    <!-- 搜索框 -->
    <div class="flayout_i_searchBox fl_fixed_search" ui-sref="shop.search">
        <div class="i_left_searchbox">
            <img src="/Content/images/search.png" alt="搜索icon"><input type="text" placeholder="搜索" class="i_search">
        </div>
        <p class="i_searchBtn">搜索</p>
    </div>
    <!--end 搜索框 -->
    <!--左侧分类-->
    <aside>
        <div class="menu-left scrollbar-none" id="sidebar">
            <ul>
                <li class="{{CurrentFcId==0?'active':''}}" ng-click="GetSecondCategory(0,'热门推荐','','')"><p>热门推荐</p></li>
                <li ng-repeat="fc in FirstCategoryList" class="{{CurrentFcId==fc.Id?'active':''}}" ng-click="GetSecondCategory(fc.Id,fc.CategoryName,fc.ADPicUrl,fc.ADUrl)"><p>{{fc.CategoryName}}</p></li>

            </ul>
        </div>
    </aside>
    <!--左侧分类-->
    <!--右侧分类内容-->
    <!--热门推荐-->
    <section class="menu-right padding-all j-content" style="display:block;" ng-show="CurrentFcId==0">
        <div class="w_prolist_hotrecimg" ng-click="go()">
            <a href="{{CurrentADUrl}}"><img ng-src="{{ImgHostUrl+CurrentADPicUrl}}" ng-click="go()" /></a>
        </div>
        <h5>热门推荐</h5>
        <ul class="w_proliproimg_all">
            <li ng-repeat="hc in HotCategoryList" ui-sref="shop.productlist({keywords:'',fcId:hc.ParentId,scId:hc.Id})">
                    <div class="w_prolipro_img imgOuterFrame">
                        <img  ng-src="{{ImgHostUrl+hc.PicUrl}}" class="imgSelf" />
                    </div>
                    <div class="w_prolipro_per">
                        <div class="w_prolipro_name">{{hc.CategoryName}}</div>

                    </div>
            </li>
        </ul>
    </section>
    <!--热门推荐-->
    <section class="menu-right padding-all j-content" style="display:block;" ng-show="CurrentFcId>0">  
            <div class="w_prolist_hotrecimg">
                <a href="{{CurrentADUrl}}"><img ng-src="{{ImgHostUrl+CurrentADPicUrl}}" ng-click="go()" /></a>
            </div>
        
        <h5>{{CurrentFcName}}</h5>
        <ul class="w_proliproimg_all">
            <li ng-repeat="sc in SecondCategoryList" ui-sref="shop.productlist({keywords:'',fcId:CurrentFcId,scId:sc.Id})">
                <div class="w_prolipro_img imgOuterFrame">
                    <img ng-src="{{ImgHostUrl+sc.PicUrl}}" class="imgSelf" />
                </div>
                <div class="w_prolipro_per">
                    <div class="w_prolipro_name">{{sc.CategoryName}}</div>

                </div>
            </li>
        </ul>
    </section>


    <!--右侧分类内容-->
    @Html.Partial("_homefoot")


</div>

<script type="text/javascript">
    App.controller('SearchIndexCtrl', [
            '$scope', '$http', '$rootScope', '$stateParams', '$state', '$filter',
        function ($scope, $http, $rootScope, $stateParams, $state, $filter) {
            $scope.CurrentFcId = 0;


            //数据初始化
            $http.post("/Product/GetHotCategory", {}).then(function (response) {
                $scope.HotCategoryList = response.data;
            });

            //数据初始化
            $http.post("/Product/GetCategoryList", {}).then(function (response) {
                $scope.CategoryList = response.data;
                $scope.FirstCategoryList = $filter('filter')(response.data, function (item) { return item.ParentId === 0; });
                $scope.CurrentADPicUrl = $scope.FirstCategoryList[0].ADPicUrl;
                $scope.CurrentADUrl = $scope.FirstCategoryList[0].ADUrl;

                //获取二级分类
                $scope.GetSecondCategory = function (fcid,fcname,adpic,adurl) {
                    $scope.SecondCategoryList = $filter('filter')($scope.CategoryList, function (item) { return item.ParentId === fcid; });
                    $scope.CurrentFcId = fcid;
                    $scope.CurrentFcName = fcname;
                    $scope.CurrentADPicUrl = adpic;
                    $scope.CurrentADUrl = adurl;
                    if (fcid == 0) {
                        $scope.CurrentADPicUrl = $scope.FirstCategoryList[0].ADPicUrl;
                        $scope.CurrentADUrl = $scope.FirstCategoryList[0].ADUrl;
                    }
                }
            });
            var tt = function () {
                $rootScope.WxShare($rootScope.pageTitle(), '优品三悦', location.href, $rootScope.LogoUrl);
            }

            setTimeout(tt, 1000)
            $scope.go = function ()
            {
                debugger;
                location.href = $scope.CurrentADUrl;
            }
        }]);
</script>

@*<script type="text/javascript">
    $(function ($) {
        $('#sidebar ul li').click(function () {
            $(this).addClass('active').siblings('li').removeClass('active');
            var index = $(this).index();
            $('.j-content').eq(index).show().siblings('.j-content').hide();
        })
    })

    $(".xd_add_and_subtract .xd_add_input").click(function () {
        // $(".xd_add_input").nextAll().hide();
        $(this).nextAll().show("slow");
        $(".xd_buy_cart_pro_num").show();

    });

    $(".xd_add_and_subtract .xd_subtract_input").click(function () {
        //$(".xd_subtract_input").prevaAll().hide();
        $(this).prev().hide();
        $(this).hide();
        $(".xd_buy_cart_pro_num").hide();

    });

</script>*@

